﻿/********************************************************************************
** @ Date:2025/05/22
** @ Author: Gaojia
** @ Description:
** @ Version:1.0.0
** @ Fun:
********************************************************************************/
#ifndef CWorkMngrBase_H
#define CWorkMngrBase_H
#include "CDevBase.h"
#include "CRBaseData.h"
#include <qdatetime.h>
#include "CAlgorithmContext.h"
#include "CThreadBase.h"
class CWorkMngrBase :public CThreadBase
{
public:
	CWorkMngrBase();
	~CWorkMngrBase();
	virtual void startWork() {};
	virtual void endWork() {};
	virtual void execEvent(int nType) {};
	virtual void init(QString sSceneGuid, CDevBase *pIFDev, CRBaseData *pRBasicData);
protected:
	virtual void taskScan();
	bool isTaskExec(int nType, int nCycType, QString sTime);//判断是否需要执行任务
	bool isTaskExec(QString sTime);//判断是否需要执行任务
	bool compareTime(QString& sTime, int nType = 0);
	bool compareTimeOverdue(QString sTime);                 //判读任务有没有超过时间没执行
	bool compareTimeEx(int nTime, QString &sReTime);
	//机器人业务逻辑事件枚举
	enum RobEventType
	{
		enSHUTDOWN,                                                     //停止
		enSUSPENDTASK,                                                  //暂停任务
		enRESETTASK,                                                    //恢复任务
		enEXECENDTASK,                                                  //结束任务
		enPROCESS,                                                      //执行巡检项
		enJUDGE,                                                        //判断流程
		enEXCEPTION,                                                    //设备异常
		enSCANTASK,                                                     //扫描任务
		enSLEEP,                                                        //线程休眠等待
	};
protected:
	CRBaseData *m_pRBaseData;
	CDevBase *m_pRobDev;
	QString m_sGuid; //设备guid
	CAlgorithmContext*m_pAlgorithmContext;       //算法处理类
	bool m_bBeltAWork;          //A侧皮带运行状态    
	bool m_bBeltBWork;          //B侧皮带运行状态
	int m_nBeltWorkCount;       //皮带运行周期
	int m_nBeltStopCount;       //皮带停止运行周期
	bool m_bAddLog;             //是否添加日志标记位 防止重复添加
};

#endif